#include <iostream>
#include <algorithm>

int n, m, x, y;

int const opt[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

bool inrange(int x, int y)
{
	return (1 <= x && x <= n) && (1 <= y && y <= m);
}

int check(int x, int y, int px, int py)
{
	if (px == x) {
		if (py > y) {
			return std::min(x, std::min(y, n-x+1));
		} else {
			return std::min(m-y+1, std::min(x, n-x+1));
		}
	} else {
		if (px > x) {
			return std::min(x, std::min(y, m-y+1));
		} else {
			return std::min(n-x+1, std::min(y, m-y+1));
		}
	}
}

int main()
{
	while (std::cin >> n >> m >> x >> y) {
		int ans = 0;
		int t1 = (n+1)/2, t2 = (m+1)/2;

		ans = std::min(t1, t2);

		if ((n&1) && (m&1)) {
			if (x == (n+1)/2 && y == (m+1)/2) {
				if (n > m) t1--;
				else	   t2--;

				ans = std::min(t1, t2);
			}
		}

		int ans2 = 0;
		for (int i = 0; i < 4; i++) {
			int px = x + opt[i][0], py = y + opt[i][1];
			if (inrange(px, py))
				ans2 = std::max(ans2, check(px, py, x, y));
		}

		std::cout << std::max(ans2, ans) << '\n';
	}
}

